namespace YPing
{
    public class Profile : IRequest
    {
        private const string PROFILE_REQUEST_FORMAT = "http://profiles.yahoo.com/{0}";

        public string GetResult(string user)
        {
            string profile = HttpHelper.GetContent(string.Format(PROFILE_REQUEST_FORMAT, user));

            string result;
            if (profile == null)
            {
                result = "Yahoo ID invalid.";
            }
            else
            {
                try
                {
                    result = HtmlHelper.ExtractField(profile, "Last Update: ");
                }
                catch
                {
                    result = "Last Update: unknown";
                }
            }

            return result;
        }
    }
}